import request from '@/utils/request'

export default {
  login(user){
    return request({
      url: '/user/login',
      method: 'post',
      data:{
        username:user.username,
        password:user.password,

      }
    });
  },
  register(user){
    return request({
      url: '/user/register',
      method: 'post',
      data:{
        username:user.username,
        password:user.password,
      }
    });
  },
  avatar(){
    return request({
      url: '/user/avatar',
      method: 'get',
    });
  },
  userInfo(){
    return request({
      url: '/user/userInfo',
      method: 'get',
    });
  },
  updateById(user){
    return request({
      url: '/user/updateById',
      method: 'post',
      data:{
        id: user.id,
        username: user.username,
        password: user.password,
        usernick: user.usernick,
        mail: user.mail,
        avatar: user.avatar
      }
    });
  },

  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params: {
        pageNow: searchModel.pageNow,
        pageSize: searchModel.pageSize,
        username: searchModel.condition,

      }
    });
  },
  deleteUser(user) {
    return request({
      url: '/user',
      method: 'delete',
      params: {
        "id":user.id
      }
    });
  },
  getUserRole(username){
    return request({
      url: '/user/getUserRoles',
      method: 'get',
      params: {
        "username":username
      }
    });
  },

  getCode(number){
    return request({
      url: '/user/code?'+number,
      method: 'get',
      
    });
  },

  saveUser(editUser,userRoleList){
    return request({
      url: '/user/add',
      method: 'post',
      data:{
        username:editUser.username,
        password:editUser.password,
        userNick:editUser.userNick,
        email:editUser.email,
        phone:editUser.phone,
        address:editUser.address,
        roleIdList:userRoleList
      }
    });
  },
  removeBatch(val){
    return request({
      url: '/user/batch',
      method: 'post',
      data: val
    });
  },
  

} 